package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type Config struct {
	Mysql struct {
		User     string
		Password string
		Host     string
		Port     int
		Database string
	}
	Redis struct {
		Host     string
		Password string
		DB       int
	}
	SendSms struct {
		AccessKeyId     string
		AccessKeySecret string
	}
	JWT struct {
		APP_KEY string
	}
	QiNiuYun struct {
		AccessKey string
		SecretKey string
	}
}

var AppConfig Config

func Init() {
	viper.SetConfigFile("../appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("配置文件读取失败")
		return
	}
	err = viper.Unmarshal(&AppConfig)
	if err != nil {
		fmt.Println("解析失败")
		return
	}
}
